import axios from "axios"
import qs from "qs"
axios.defaults.baseURL = process.env.VUE_APP_BASE_API;
axios.interceptors.request.use(function (config) {
    return config;
}, function (error) {
    return Promise.reject(error);
});
axios.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    return Promise.reject(error);
});
class http{
    static get(url,params){
        return axios.get(url,{params:params})
    }
    static post(url,params){
        console.log(qs.stringify(params))
        return axios.post(url,qs.stringify(params))
    }
}

function uploadheadimg(url,callback,params) {
    let data = new FormData()
    data.append('headfile',params.headfile)
    axios.post(url,data).then((res)=>{
        callback(res)
    })
}

export {http,uploadheadimg};